#include "TcpServer.hpp"
#include "InetAddr.hpp"
#include "Socket.hpp"
#include "Protocol.hpp"
#include "NetCal.hpp"
#include "Daemon.hpp"
using namespace SocketMoudule;
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        LOG(Level::FATAL) << "Usage server port";
        exit(USAGE_ERRO);
    }
    Enable_File_Log_Strategy();
    Daemon(0, 0);
    // 务业
    unique_ptr<NetCal> nc(make_unique<NetCal>());
    // 协议
    unique_ptr<Protocol> pt(make_unique<Protocol>([&](Request &req) -> Response
                                                  { return nc->Execute(req); }));
    // 通通信
    unique_ptr<TcpServer> ts(make_unique<TcpServer>(stoi(argv[1]), [&](shared_ptr<Socket> sock, InetAddr addr)
                                                    { pt->GetRequest(sock, addr); }));
    return 0;
}